//#Author:bin
// -*- charset = utf-8 -*-
// @time:2022/2/17 16:14
// @Author:bfl91
// @file : classcation.js
// @Software:WebStorm

import http from "../api/http";
export default {
    namespaced:true,
    state:{
        classlist:[]||localStorage.getItem('classlist')//分类数据
    },
    mutations: {
        setclass(state,list){
            state.classlist=list
        }
    },
    actions: {
        getclass(contxt){
            if(contxt.state.classlist.length>0){
                return
            }
            http('categories').then(res=>{
                localStorage.setItem('classlist',JSON.stringify(res.message))
                contxt.commit('setclass',res.message)
            });
        }
    },
}